<template>
	<view class="content">		
		<u-picker :show="showPicker" :columns="pickerList" closeOnClickOverlay @close="closePicker()"
			@cancel="closePicker()" @confirm="confirmPicker" keyName="name"></u-picker>
		<mescroll-uni ref="mescrollRef" @init="mescrollInit" @up="upCallback" :up="upOption" :down="{use: false}">
		<view class="section-0">
				<view class="wrapper" style="margin-top: 54rpx;">
					<view class="title"><text class=""></text>2022年2月</view>
					<view class="value" >
						<view class="report">
							<text class="report-title">省招第一批</text>
						</view>
						<view class="report">
							<view class="device">
								<view class="device-info">
									<text>计划上报时间:2022-02-02</text>
									<text>截至时间:2022-02-02</text>
								</view>
								<view class="device-info">
									<text>公告上报时间:2022-02-02</text>
									<text>截至时间:2022-02-02</text>
								</view>
							</view>
						</view>
						<view class="report">
							<text class="report-title">授权采购第一批</text>
						</view>
						<view class="report">
							<view class="device">
								<view class="device-info">
									<text>计划上报时间:2022-02-02</text>
									<text>截至时间:2022-02-02</text>
								</view>
								<view class="device-info">
									<text>公告上报时间:2022-02-02</text>
									<text>截至时间:2022-02-02</text>
								</view>
							</view>
						</view>
					</view>
				</view>
				<view v-if="false" class="wrapper" style="width: 100%;padding: 0 40rpx;margin-left: 0;
				border-radius: 35rpx 35rpx 0 0;margin-top: 53rpx;">
					<view class="value" style="border-bottom: solid 3rpx #f2f2f0;padding-bottom: 37rpx;">
						<view class="report">
							<view class="report-item">
								<view class="top"><text class="t1">待报计划个数</text></view>
								<view class="bottom"><text class="t2">66</text></view>
							</view>
							<view class="report-item" style="justify-content: center;">
								<view style="width: 5rpx;height: 86rpx;
								background-color: #f2f2f0;margin: auto;margin-top: 20rpx;"></view>
							</view>
							<view class="report-item">
								<view class="top"><text class="t1">计算总数</text></view>
								<view class="bottom"><text class="t2">66</text></view>
							</view>
						</view>	
						<view class="report">
							<view class="report-item">
								<view class="top"><text class="t3">合同总数:XX</text></view>
							</view>
							<view class="report-item" style="text-align: center;">
								<view class="top"><text class="t3">合同总金额:XX</text></view>
							</view>
							<view class="report-item">
								<view class="top"><text class="t3">累计总支付金额:XXXX</text></view>
							</view>
						</view>		
					</view>

					<view class="form">
						<view class="form-item">
							<view class="label">项目名称</view>
							<view class="shape"></view>
							<view class="input">
								<u--input
									placeholderClass="input-placeholder"
									class="input-body"
								  ></u--input>
							</view>
						</view>
						<view class="actions" >
							<view class="action" @click="handleResetForm">
								<text>重</text>
								<text>置</text>
							</view>
							<view style="width: 20rpx;">
								
							</view>
							<view class="action search" @click="handleSearch">
								<text>查</text>
								<text>询</text>
							</view>
						</view>
					</view>

					<view class="list">
						<view class="item" v-for="(item, index) in list" :key="item.id + index">
							<view class="parent"  @click="go('/pages/statistics/manufacture/contract/info/index?id='+item.id)">
								<view class="name">{{index + 1}}.{{item.project_name}}</view>
								<view class="action" @click="expandChange(item.id)">
									<view class="iconfont icon-xiangyou1"></view>
								</view>
							</view>
							
							<view class="child" v-if="expandList.indexOf(item.id) !== -1" @click="go(item2)">
								<view class="child-item" v-for="(item2, idx) in item.children" :key="item2.id + idx">
									<view class="top">
										<view class="name">
											{{index + 1}}-{{idx + 1}}.{{item2.project_name}}
										</view>
										<view class="desc">
											<text>合同执行</text>
											<text>XXX招标</text>
										</view>
									</view>
								</view>
							</view>
						</view>
					</view>


				</view>
			</view>
		</mescroll-uni>
	</view>
</template>

<script>
	import {
		powerListtApi
	} from '@/api/project.js';
	import {
		mapGetters,
		mapActions
	} from 'vuex';
	export default {
		data() {
			return {
				form: {
					projectName: '',
					type: ''
				},
				board: [{
						name: '国家级创优项目数量',
						count: 0,
						right: true
					},
					{
						name: '省部级创优项目数量',
						count: 0,
						right: true
					},
					{
						name: '地市级创优项目数量',
						count: 0
					},
				],
				mescroll: null, // mescroll实例对象 (此行可删,mixins已默认)
				upOption: {
					textNoMore: '-- 没有更多了 --'
				},
				pageSize: 20,
				list: [],
				showPicker: false,
				pickerList: [
					[{
							id: 1,
							name: '全部',
							type: ''
						},
						{
							id: 2,
							name: '未开始',
							type: '2'
						},
						{
							id: 3,
							name: '进行中',
							type: '3'
						},
						{
							id: 4,
							name: '已结束',
							type: '4'
						},
					]
				],
				expandList: [
					{
						id:1,
						project_name:"12123",
					}
				],
			};
		},
		methods: {
			go(url) {
				uni.navigateTo({
					url
				})
			},
			async expandChange(id) {
				const idx = this.expandList.indexOf(id);
				if (idx !== -1) {
					this.expandList.splice(idx, 1);
				} else {
					this.expandList.push(id);
				}
			},
			openPicker() {
				this.showPicker = true;
			},
			closePicker() {
				this.showPicker = false;
			},
			confirmPicker(e) {
				const {
					value
				} = e;
				const item = value[0]; // {id: 7, name: '未开'}
				this.form.type = item.type;
				this.closePicker();
			},
			/*mescroll组件初始化的回调,可获取到mescroll对象 (此处可删,mixins已默认)*/
			mescrollInit(mescroll) {
				this.mescroll = mescroll;
			},
			/*上拉加载的回调*/
			async upCallback(page) {
				const {
					data
				} = await powerListtApi({
					...this.form,
					page: page.num,
					pageSize: this.pageSize
				});
	
				if (data.code === 1 || data.code === 200) {
					// this.board[0].count = data.data.total_num;
					// this.board[1].count = 0;
					// this.board[2].count = 0;
					// 接口返回的当前页数据列表 (数组)
					let curPageData = data.data.data;
					// 接口返回的当前页数据长度 (如列表有26个数据,当前页返回8个,则curPageLen=8)
					let curPageLen = curPageData.length;
					// 接口返回的总页数 (如列表有26个数据,每页10条,共3页; 则totalPage=3)
					let totalPage = data.data.last_page;
					//设置列表数据
					if (page.num == 1) this.list = []; //如果是第一页需手动置空列表
					this.list = this.list.concat(curPageData); //追加新数据
					// 请求成功,隐藏加载状态
					this.mescroll.endByPage(curPageLen, totalPage);
					setTimeout(() => {
						this.mescroll.endSuccess(curPageLen);
					}, 20);
				} else {
					//  请求失败,隐藏加载状态
					this.mescroll.endErr()
				}
			},
			handleResetForm() {
				for (let key in this.form) {
					this.form[key] = '';
				}
				this.mescroll.resetUpScroll();
				this.mescroll.scrollTo(0, 0);
			},
			handleSearch() {
				this.mescroll.resetUpScroll();
				this.mescroll.scrollTo(0, 0);
			},
		}
	}
</script>
<style lang="scss" scoped>
	.content{

		.section-0{
			.wrapper{
				width: calc(750rpx - 80rpx);
				margin-left: 40rpx;
				border-radius: 35rpx;
				background-size: cover;
				background-repeat: no-repeat;
				overflow: hidden;
				box-sizing: border-box;
				box-shadow: 0 0 20rpx 10rpx rgba(#bcbcb5, 0.17);
				padding: 28rpx 40rpx;
				// margin-bottom: 24rpx;
				.title {
					font-size: 26rpx;
					line-height: 49rpx;
					letter-spacing: 0rpx;
					color: #7f98ae;
					width: 100%;
					border-bottom: solid 3rpx #f2f2f0;
					font-stretch: normal;
					letter-spacing: 0rpx;
					padding-bottom: 28rpx;
					.iconfont{
						font-size: 26rpx;
						color: #1534ce;
						margin-right: 10rpx;
					}
					view {
						float: right;
						font-size: 26rpx;
						color: #8497ac;
						font-weight: normal;
						.iconfont{
							font-size: 26rpx;
							margin-right: 5rpx;
						}
					}
				}
				.device{
					width: 100%;
					padding-top: 35rpx;
					padding-bottom: 43rpx;
					.device-title{
						font-size: 26rpx;
						padding-bottom: 20rpx;
						color: #8497ac;
					}
					.device-info{
						@include clear();
						text{
							display: inline-block;
							float: left;
							text-align: left;
							&:last-child{
								float: right;
								text-align: right;
							}
							// width: 234rpx;
							// height: 53rpx;
							font-family: SourceHanSansCN-Regular;
							font-size: 19rpx;
							font-weight: normal;
							font-stretch: normal;
							line-height: 49rpx;
							letter-spacing: 0rpx;
							color: #3b3c40;
						}
					}
				}
				.value {
					width: 100%;
					padding-top: 28rpx;
					// padding-bottom: 28rpx;
					// border-bottom: solid 3rpx #f2f2f0;
					
					.report{
						width: 100%;
						@include clear();
						.report-title{
							font-size: 30rpx;
						}
						.report-item{
							width: 33%;
							float: left;
							text-align: center;
							.top{
								width: 100%;
								font-size: 26rpx;
								color: #9b9b9b;
							}
							.bottom{
								font-size: 40rpx;
								color: #1534ce;
								font-weight: bold;
								padding-top: 30rpx;
							}
							
						}
					}
					.small{
						.report-item{
							width: 25%;
						}
					}
					.record{
						width: 100%;
						@include clear();
						margin-bottom: 25rpx;
						.left{
							width: 100%;
							float: left;
							font-size: 26rpx;
							line-height: 36rpx;
							color: #3b3c40;
							margin-bottom: 10rpx;
						}
						
						.log{
							width: 100%;
							line-height: 28rpx;
							font-size: 20rpx;
							color: #3b3c40;
						}
						&:last-child{
							margin-bottom: 0;
						}
					}
				}
				.form{
					width: 100%;
					// padding: 0 75rpx;
					padding-top: 40rpx;
					box-sizing: border-box; 
					.form-time{
						width: 600rpx;
						min-height: 48rpx;
						margin: 0 auto;
						margin-bottom: 25rpx;
						@include clear;
						.label{
							float: left;
							width: 134rpx;
							height: 48rpx;
							text-align: center;
							line-height: 44rpx;
							font-size: 26rpx;
							font-weight: normal;
							font-stretch: normal;
							letter-spacing: 0rpx;
							color: #1534ce;
						}
						.wrapper{
							float: left;
							width: calc(100% - 134rpx);
							line-height: 48rpx;
							.item{
								float: left;
								display: inline-block;
								height: 48rpx;
								border-radius: 35rpx;
								padding: 0 20rpx;
								background-color: #395cf5;
								text-align: center;
								font-size: 26rpx;
								line-height: 48rpx;
								color: #fff;
								margin-left: 10rpx;
								transition: 0.3s ease;
							}
							.item__active{
								background-color: #1534ce;
							}
						}
					}
					.form-item{
						width: 600rpx;
						height: 48rpx;
						border-radius: 20rpx;
						border: solid 2rpx #1534ce;
						margin: 0 auto;
						margin-bottom: 25rpx;
						&:last-child{
							margin-bottom: 34rpx;
						}
						@include clear();
						.label{
							float: left;
							width: 134rpx;
							height: 48rpx;
							text-align: center;
							line-height: 44rpx;
							font-size: 26rpx;
							font-weight: normal;
							font-stretch: normal;
							letter-spacing: 0rpx;
							color: #1534ce;
						}
						.shape{
							width: 3rpx;
							height: 32rpx;
							background-color: #7f98ae;
							float: left;
							margin-top: 8rpx;
						}
						.input{
							float: left;
							width: calc(100% - 134rpx - 3rpx);
							.input-body{
								box-sizing: border-box;
								width: 100%;
								height: 44rpx;
								padding: 0!important;
								border: none;
								padding-left: 30rpx!important;
								padding-right: 30rpx!important;
								font-size: 26rpx;
								font-weight: normal;
								font-stretch: normal;
								letter-spacing: 0rpx;
								color: rgba(0,0,0,0.7);
							}
							.input-placeholder{
								font-size: 26rpx;
								font-weight: normal;
								font-stretch: normal;
								letter-spacing: 0rpx;
								color: rgba(0,0,0,0.5);
							}
						}	
					}
				}
				.actions{
					width: 100%;
					height: 50rpx;
					margin-top: 29rpx;
					padding-bottom: 40rpx;
					display: flex;
					justify-content: center;
					.action{
						width: 288rpx;
						height: 48rpx;
						background-color: #395cf5;
						border-radius: 20rpx;
						text-align: center;
						line-height: 48rpx;
						font-size: 26rpx;
						font-weight: normal;
						font-stretch: normal;
						color: #ffffff;
						text{
							&:first-child{
								margin-right: 20rpx;
							}
						}
					}
					.search{
						background-color: #1534ce;
					}
				}
		.list {
			width: 670rpx;
			box-sizing: border-box;
			margin-left: 40rpx;
			border-top: 2rpx solid #d8e4f2;

			.item {
			
				width: 100%;
				border-bottom: solid 2rpx #f2f2f0;
					
				.parent {
					width: 100%;
					@include clear();
					.name {					
						width: calc(100% - 50rpx);
						line-height: 30rpx;
						padding: 26rpx 0;
						font-size: 26rpx;
						font-weight: normal;
						font-stretch: normal;
						letter-spacing: 2rpx;
						color: #3b3c40;
						float: left;
					}
					
					.count {
						float: right;
						min-width: 46rpx;
						height: 46rpx;
						margin-top: 18rpx;
						border-radius: 28rpx;
						line-height: 46rpx;
						text-align: center;
						font-size: 26rpx;
						font-weight: bold;
						color: #395cf5;
						background: #ffde00;
						text {
							font-size: 16rpx;
						}
					}
					
					.action {
						float: left;
						width: 32rpx;
						margin-right: 18rpx;
						line-height: 82rpx;
						text-align: center;
						color: #3b3c40;
					
						.iconfont {
							font-size: 32rpx;
							transition: 0.2s ease;
							transform: rotate(90deg);
						}
					
					}
				}
				.child {
					width: 770rpx;
					margin-left: - 80rpx;
					background: #f2f2fa;
					
					.child-item {
						
						width: 100%;
						border-bottom: 2rpx solid #e3e8f5;
						box-sizing: border-box;
						padding-left: 50rpx;
						@include clear();
						&:last-child {
							border-bottom: none;
						}
						
						
						.top {
							width: 100%;
							overflow: hidden;
							box-sizing: border-box;
							padding-left: 40rpx;
					
							.name {
								float: left;
								width: 100%;
								box-sizing: border-box;
								padding: 26rpx 0;
								font-size: 26rpx;
								color: #3b3c40;
								font-size: 26rpx;
							}
							.desc{
								float: left;
								width: 100%;
								font-size: 16rpx;
								color: #9b9b9b;
								box-sizing: border-box;
								padding-left: 50rpx;
								padding-bottom: 26rpx;
								padding-right: 75rpx;
								text{
									padding: 0 20rpx;
									height: 30rpx;
									border-radius: 15rpx;
									border: solid 2rpx #1534ce;
									font-size: 15rpx;
									line-height: 30rpx;
									display: inline-block;
									color: #1534ce;
									margin-left: 25rpx;
									float: left;
								}
							}
							.action {
								width: 32rpx;
								line-height: 82rpx;
								float: left;
								text-align: center;
								color: #7f98ae;
								margin-right: 18rpx;
								.iconfont {
									font-size: 32rpx;
									transition: 0.2s ease;
									transform: rotate(90deg);
								}
							}
						}
					}
				}
				
				.grad{
					width: 100%;
					background: #d9d9e2;
					.grad-item{
						width: 100%;
						border-bottom: 2rpx solid #e3e8f5;
						
						&:last-child {
							border-bottom: none;
						}
						
						.grad-top {
							width: 100%;
							overflow: hidden;
							box-sizing: border-box;
							padding-left: 40rpx;
							.name {
								float: left;
								width: calc(100% - 40rpx);
								padding: 26rpx 0;
								padding-bottom: 10rpx;
								font-size: 26rpx;
								color: #3b3c40;
								padding-left: 50rpx;
								box-sizing: border-box;
							}
							.desc{
								float: left;
								width: calc(100% - 40rpx);
								font-size: 16rpx;
								color: #9b9b9b;
								box-sizing: border-box;
								padding-left: 50rpx;
								padding-bottom: 26rpx;
								text{
									min-width: 300rpx;
									margin-right: 30rpx;
									display: inline-block;
								}
							}
						}
					}
				}
				.action__active{
					.iconfont{
						transform: rotate(-90deg)!important;
					}
				}
				
			}
		}

		.actions {
			width: 100%;
			height: 50rpx;
			margin-top: 29rpx;
			padding-bottom: 40rpx;
			display: flex;
			justify-content: space-between;

			.action {
				width: 288rpx;
				height: 48rpx;
				background-color: #395cf5;
				border-radius: 20rpx;
				text-align: center;
				line-height: 48rpx;
				font-size: 26rpx;
				font-weight: normal;
				font-stretch: normal;
				color: #ffffff;

				text {
					&:first-child {
						margin-right: 20rpx;
					}
				}
			}

			.search {
				background-color: #1534ce;
			}
		}

				
				
				
			}
		}
	}
	
	.t1{
		font-family: SourceHanSansCN-Medium;
		font-size: 15rpx;
		font-weight: normal;
		font-stretch: normal;
		line-height: 49rpx;
		letter-spacing: 0rpx;
		color: #3b3c40;
	}
	.t2{
		font-family: SourceHanSansCN-Bold;
		font-size: 58rpx;
		font-weight: normal;
		font-stretch: normal;
		line-height: 49rpx;
		letter-spacing: 0rpx;
		color: #ffdc00;
	}
	.t3{
		font-family: SourceHanSansCN-Regular;
		font-size: 15rpx;
		font-weight: normal;
		font-stretch: normal;
		line-height: 49rpx;
		letter-spacing: 0rpx;
		color: #3b3c40;
	}
	
	
</style>
